//
//  LYSecondViewController.m
//  MusicMV
//
//  Created by dllo on 16/3/18.
//  Copyright © 2016年 Eternity. All rights reserved.
//

#import "LYSecondViewController.h"

@interface LYSecondViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain) UITableView *bigTableView;
@end

@implementation LYSecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = _nameStr;
    //去掉navigation下面的线
    [[UINavigationBar appearance] setShadowImage:[UIImage new]];
    [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    
    self.navigationController.navigationBar.translucent = YES;
   // 给navigation放一张图片
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"zhezhaoceng_shang~iphone"] forBarMetrics:UIBarMetricsDefault];
    
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"iconfont-fanhui"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(leftItemAction:)];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"iconfont-shixin"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]style:UIBarButtonItemStylePlain target:self action:@selector(rightItemAction:)];
    UIBarButtonItem *rightItem2 = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"iconfont-zhuanfa"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]style:UIBarButtonItemStylePlain target:self action:@selector(rightItem2Action:)];
    self.navigationItem.rightBarButtonItems = @[rightItem2, rightItem];
    

    [self createTableView];
    
    [self dataHandle];
    
    
}

- (void)createTableView {
    self.bigTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, -64, WIDTH, HEIGHT - 49) style:UITableViewStylePlain];
    [self.view addSubview:_bigTableView];
    
    _bigTableView.delegate = self;
    _bigTableView.dataSource = self;
    
    [_bigTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"bigTableView"];
    
    UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, (HEIGHT - 49) / 2)];
    [self.view addSubview:headView];
    _bigTableView.tableHeaderView = headView;
    headView.backgroundColor = [UIColor redColor];
    
    
}

#pragma mark - tableView Datasource & delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"bigTableView"];
    return cell;
}

#pragma mark - item 点击方法

- (void)leftItemAction:(UIBarButtonItem *)item {
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

- (void)rightItemAction:(UIBarButtonItem *)item {
    
}

- (void)rightItem2Action:(UIBarButtonItem *)item {
    
}


#pragma mark - 数据解析
- (void)dataHandle {
    [XRAFNetworkTool POSTUrl:[NSString stringWithFormat:@"http://api.enjoymusicapp.com/api/v1.0/bigSong/detail.ema?sign=%@&uid=0&version=2.3.2&platform=ios", self.ID] body:@{@"sid" : @"1615294", @"uid" : @"0"} requestBodyStyle:XRRequestJSON headFile:@{@"Host" : @"api.enjoymusicapp.com", @"Proxy-Connection" : @"keep-alive", @"Accept" : @"*/*", @"Content-Length" : @"17", @"User-Agent" : @"enjoy/2.3.2 (iPhone; iOS 8.4.1; Scale/2.00) Paros/3.2.13"} response:XRJSON success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSLog(@"%@", responseObject);
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
